const BeforeUrl =
  "https://www.fastmock.site/mock/73c09ac2e35e73935f8e671dedb95da8/look/";

const http = {
  get(url, parmes) {
    if (parmes) {
      let attr = [];
      for (let key in parmes) {
        attr.push(key + "=" + parmes[key]);
      }
      url += "?" + attr.join("&");
    }
    return fetch(BeforeUrl + url)
      .then((response) => response.json())
      .then((res) => {
        return res;
      });
  },
  post(url, data) {
    return fetch(BeforeUrl + url, {
      body: JSON.stringify(data), // must match 'Content-Type' header
      headers: {
        "content-type": "application/json",
      },
      method: "POST", // *GET, POST, PUT, DELETE, etc.
    })
      .then((response) => response.json())
      .then((res) => {
        return res;
      });
  },
};
export default http;
